/**
 * Provides main application functionality. Sets up signals and slots for
 * the Qt components
 *
 * This code follows GPL V3 Licensing
 *
 * B. Jones 2011.
 *
 */

#include <QApplication>
#include <QMainWindow>
#include "uiEncap.h"
#include "guiWrapper.h"

/**
 * uiEncap encapsulates a static instantiation of the main user interface framework
 * Its a quick and convenient hack that enables easy access without the need to
 * pass too many pointers around
 */
Ui_MainWindow *uiEncap::ui=new Ui_MainWindow;

int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QMainWindow *win=new QMainWindow;
	guiWrapper gw;
	//Ui_MainWindow *ui;
	uiEncap::ui->setupUi(win);
	uiEncap::ui->chatInput->listener_=&gw;

	uiEncap::ui->fileSendProgress->setValue(0);
	uiEncap::ui->fileReceiveProgress->setValue(0);

	uiEncap::ui->fileSendProgress->setMaximum(100);
	uiEncap::ui->fileReceiveProgress->setMaximum(100);

	uiEncap::ui->chatInput->setEnabled(false);
	uiEncap::ui->sendButton->setEnabled(false);
	uiEncap::ui->syncButton->setEnabled(false);

	uiEncap::ui->serverStartButton->setStyleSheet(
				 "border-style: outset;"
				 "border-width: 5px;"
				 "border-color: beige;"
	);
	uiEncap::ui->connectButton->setStyleSheet(
					 "border-style: outset;"
					 "border-width: 5px;"
					 "border-color: beige;"
	);

	// Connect gui buttons to their functions within swg
	QObject::connect ( uiEncap::ui->serverStartButton, SIGNAL( clicked() ), &gw, SLOT( serverButtonClicked() ) );
	QObject::connect ( uiEncap::ui->connectButton, SIGNAL( clicked() ), &gw, SLOT( connectButtonClicked()) );
	QObject::connect ( uiEncap::ui->sendButton, SIGNAL( clicked() ), &gw, SLOT( sendButtonClicked() ) );
	QObject::connect ( uiEncap::ui->syncButton, SIGNAL( clicked() ), &gw, SLOT( syncButtonClicked() ) );

	win->show();
	return app.exec();
}
